/*
 * @Author: Bowen 849084209@qq.com
 * @Date: 2023-02-09 22:25:14
 * @FilePath: \ming\ming-util\src\main\java\com\ming\ming\model\AckMessage.java
 * @Description: 发送的消息体
 */
package com.ming.ming.model;

import com.ming.ming.MingConfig;

public class MingMessage {

    private Integer sourceId;
    private Integer targetId;
    private String msg;


    private MingMessage(Integer sourceId, Integer targetId, String msg) {
        this.sourceId = sourceId;
        this.targetId = targetId;
        this.msg = msg;
    }
    
    /**
     * 初始化
     */
    public static MingMessage init(Object payload){
        String[] msgArray = String.valueOf(payload).split(MingConfig.fenGe);
        return new MingMessage(Integer.valueOf(msgArray[0]),Integer.valueOf(msgArray[1]),msgArray[2]);
    }

    public Integer getSourceId() {
        return sourceId;
    }
    public void setSourceId(Integer sourceId) {
        this.sourceId = sourceId;
    }
    public Integer getTargetId() {
        return targetId;
    }
    public void setTargetId(Integer targetId) {
        this.targetId = targetId;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "MingMessage [sourceId=" + sourceId + ", targetId=" + targetId + ", msg=" + msg + "]";
    }
    
}
